from starlette.endpoints import HTTPEndpoint
from starlette.responses import JSONResponse
from model.ModBureauWeeklyRep import BureauWeeklyRep, bureauWeeklyRepSchema
from database import Session, engine
import datetime
from sqlalchemy import Date, DateTime


def get_weeklyrep_info(session, monthnum: Date, weeknum: int, area_flag: str):
    # 根据月份查询供电局指标排名月报
    weeklyrep_info = session.query(BureauWeeklyRep).filter(BureauWeeklyRep.monthnum == monthnum).filter(
        BureauWeeklyRep.weeknum == weeknum).filter(
        BureauWeeklyRep.area_flag == area_flag).order_by(BureauWeeklyRep.bureauid.asc()).all()
    return JSONResponse(bureauWeeklyRepSchema.dump(weeklyrep_info, many=True).data)
